<template>
    <div>
      退单详情
      <div>
        退单状态:{{ info.status | filterStatus}}
      </div>
      <div v-if="info.status == 0">
        <el-form :model="form" ref="form"  label-width="80px" :inline="true" size="normal">
          <el-form-item label="退款金额">
            <el-input-number v-model="form.returnAmount"  ></el-input-number>
          </el-form-item>
          <el-form-item label="处理人">
            <el-input v-model="form.handleMan"  ></el-input>
          </el-form-item>
          <el-form-item label="处理备注">
            <el-input v-model="form.handleNote"  ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">同一退款</el-button>
            <el-button>拒绝退款</el-button>
          </el-form-item>
        </el-form>
        
      </div>
      <div v-if="info.status == 1">
        <el-form :model="formData" ref="form" :rules="rules" label-width="80px" :inline="false" size="normal">
          <el-form-item label="收货人">
            <el-input v-model="form.receiveMan"></el-input>
          </el-form-item>
          <el-form-item label="收货备注">
            <el-input v-model="form.receiveNote"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="confirm">确认收货</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
        
      </div>
    </div>
</template>

<script>
import {
  orderReturn,
  agreeApply,
  receiveProduct
} from "@/api/orderManage/returnOrderInfo/index"
export default {
    data() {
        return {
          info:{},
          form:{
            id:this.$route.params.id,
            handleMan:"",
            handleNote:"",
            returnAmount:""
          },
          formData:{
            id:this.$route.params.id,
            receiveMan:"",
            receiveNote:""
          }
        };
    },
    computed: {

    },
    filters:{
      filterStatus(val){
        var arr = ["待处理","退货中","已完成","已拒绝"];
        return arr[val]
      },
    },
    created() {
     this.init()
    },
    mounted() {

    },
    methods: {
      confirm(){
        receiveProduct(this.$route.params.id,this.formData)
        .then(res =>{
          this.init()
        })
      },
      init(){
        orderReturn(this.$route.params.id)
        .then(res =>{
          console.log(res)
          this.info = res.data.orderReturnApply;
        })
      },
      onSubmit(){
        agreeApply(this.$route.params.id,this.form)
        .then(res =>{
          this.init()
        })
      }
    },
};
</script>

<style scoped lang="scss">

</style>
